﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Meqs.Entity;
using Meqs.Logic.Interface;
using Meqs.Logic;

public partial class Education_Report_SelectScoreEducation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected int currPage = 1;
    protected void btnBind_Click(object sender, EventArgs e)
    {
        string subjid = textSubjID.Text;
        string strType = textType.Text;
        string strScore = textScore.Text;
        IGradeScoreEducationLogic logic = Container<IGradeScoreEducationLogic>.Instance;
        Hashtable ht = new Hashtable();
        ht.Add("ExamID",EducationCookie.ExamID);
        ht.Add("SubjectID", Convert.ToInt32(subjid));
        if (Convert.ToInt32(subjid)>0)
        {
            ht.Add("Condition", "score " + strType + strScore);
        }
        else
        {
            ht.Add("Condition", "sum(score) " + strType + strScore);
        }
       
        ht.Add("TableName", CommonScore.GetGradeStoreTable(EducationCookie.ExamGrade));
        ht.Add("Number", Convert.ToInt32(strScore));
        if (CommonScore.GetAreaID != 0)
        {
            ht.Add("Areaid", CommonScore.GetAreaID);
        }
        ht.Add("MSAreaid", CommonScore.GetAreaID);
        ht.Add("StrType", strType);
        ht.Add("Score", strScore);
        IList<SchoolExamInfo> list = logic.GetSchoolScoreNum(ht);

        if (strType == ">=")
        {
            ListSort<SchoolExamInfo> sort = new ListSort<SchoolExamInfo>(list, "RowIndex", true);
            list = sort.Sort();
        }
        else
        {
            ListSort<SchoolExamInfo> sort = new ListSort<SchoolExamInfo>(list, "RowIndex", false);
            list = sort.Sort();
        }

        AspNetPager1.RecordCount = list.Count;
        List<SchoolExamInfo> ttemp = new List<SchoolExamInfo>();
        for (int i = 0; i < list.Count; i++)
        {
            if ((i + 1) <= currPage * AspNetPager1.PageSize && (i + 1) > (currPage - 1) * AspNetPager1.PageSize)
            {
                ttemp.Add(list[i]);
            }
        }

        if (ttemp.Count <= AspNetPager1.PageSize)//若是绑定数据行数小于等于一页数据行数 怎不显示分页控件
            AspNetPager1.Visible = false;
        else
            AspNetPager1.Visible = true;

        Repeater1.DataSource = ttemp;
        Repeater1.DataBind();
    }
    protected void AspNetPager1_PageChanged(object src, EventArgs e)
    {
        Wuqi.Webdiyer.PageChangedEventArgs pc = e as Wuqi.Webdiyer.PageChangedEventArgs;
        currPage = pc.NewPageIndex;
        AspNetPager1.CurrentPageIndex = currPage;
        btnBind_Click(null, null);
    }
}
